package cc.linker.steplink.crm.controller;

import cc.linker.steplink.crm.commons.utils.IPUtil;
import cc.linker.steplink.crm.service.EventMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Description: 接收微信矩阵的行为信息
 * @Author: wuyue
 * @Date: 2019/8/30 10:14
 * @Version: v1.8.3
 */
@RestController
@RequestMapping("/eventmsg")
public class EventMsgController {

    @Autowired
    private EventMsgService eventMsgService;

    /**
     * @Description:接收矩阵推送的行为
     * @Param:CreateTime 创建时间
     * @Param:token token
     * @Param:openId openid
     * @Param:MsgType 消息类型
     * @Param:EventType 事件类型
     * @Param:EventKey 事件key(数组)
     * @Return:void
     * @Author: wuyue
     * @Date: 2019/8/30 10:19
     * @Version: v1.8.3
     */
    @PostMapping("/wxevent")
    public void wxevent(@RequestBody Map<String, Object> map,HttpServletRequest request) {
//        LOGGER.info("接收矩阵推送的行为ip:"+IPUtil.getIp(request));
        eventMsgService.saveEvent(map);
    }

}
